package com.wanxi.test;

import java.util.Scanner;

public class PrintHelloWorld {
    public static void main(String[] args) {
        /**
         * 打印n次HelloWorld
         * 1.n
         * 2.打印
         */
        int time = getNum("请输入你要打印的次数");
        String words = getString("请输入你要打印的文字");
        printWords(time, words);
    }

    private static void printWords(int time, String words) {
        for (int i = 0; i < time; i++) {
            System.out.println("第 " + (i + 1) + " 次 " + words);
        }
    }

    /**
     * 得到返回的值
     *
     * @param tips
     * @return
     */
    private static String getString(String tips) {
        Scanner scanner = new Scanner(System.in);
        System.out.println(tips);
        String str = scanner.next();
        return str;
    }

    private static int getNum(String tips) {
        Scanner scanner = new Scanner(System.in);
        System.out.println(tips);
        int num = scanner.nextInt();
        return num;
    }
}
